<?php

namespace business\company\repositories;

use yii\db\Query;

class SelectionSupplierProjectRepository
{
    /**
     * 通过时间区间获取供应商ID列表
     * @param string $startDate 开始时间
     * @param string $endDate
     * @return array 供应商ID列表
     * @throws \yii\base\InvalidConfigException
     */
    public function getSupplierIdsByTimeSlot($startDate, $endDate)
    {
        $connection = \Yii::$app->get('dbSupplier');
        $sql = "select supplier_id from `b2b_supplier`.`supplier_project` 
                where (`publish_time` >= :startDate and `publish_time` <= :endDate) 
                or (`audit_time` >= :startDate and `audit_time` <= :endDate) 
                or (`updated_at` >= :startDate and `updated_at` <= :endDate)
                group by supplier_id";
        return $connection->createCommand($sql)
            ->bindValue(':startDate', $startDate)
            ->bindValue(':endDate', $endDate)
            ->queryColumn();
    }
}
